//
//  Background.h (Level 1)
//  GameProject
//
//  Created by Blair Trusler on 21/07/2011.
//  Copyright Blair Trusler 2011. All rights reserved.
//

#import "GameHeader.h"
#import "HUD.h"

@class EnemySprite;
@class PlayerSprite;
@class PathNode;

#define TILE_OPEN 0
#define TILE_WALL 1
#define TILE_START 2
#define TILE_FINISH 3
#define TILE_MARKED 4
#define TILE_TAG 100
#define TILE_ROWS 40
#define TILE_COLS 40

@interface Background : CCLayer{
    CCTMXTiledMap *_tileMap;
    CCTMXLayer *_background; 
    CCTMXLayer *_foreground;
    CCTMXLayer *_meta;
    CCSprite *_player;
    CCSpriteBatchNode *_playerSprite;
    HUD *_hud;
    
    CGPoint enemySpawnPos1;
    PlayerSprite *playerOne;
    EnemySprite *enemyOne;
        
    unsigned char tileArray[TILE_COLS][TILE_ROWS]; 
        
	NSMutableArray *pointerToOpenList;
    
    int startX, startY, endX, endY;
    
    NSMutableArray *movementPathX, *movementPathY;
    
    BOOL allowDiags;
}

@property (nonatomic, retain) CCTMXTiledMap *tileMap;
@property (nonatomic, retain) CCTMXLayer *background;
@property (nonatomic, retain) CCTMXLayer *foreground;
@property (nonatomic, retain) CCTMXLayer *meta;
@property (nonatomic, retain) CCSprite *player;
@property (nonatomic, retain) CCSpriteBatchNode *playerSprite;
@property (nonatomic, retain) HUD *hud;
@property BOOL allowDiags;
@property int startX;
@property int startY;
@property int endX;
@property int endY;

-(PathNode *)lowestCostNodeInArray:(NSMutableArray*)openList1;

-(void) createPath:(ccTime)dt;
-(void) clear:(id) sender;
-(BOOL) isWall:(CGPoint) position;
-(BOOL) findPath:(int)sx :(int)sy :(int)ex :(int)ey;
-(void) flipTileArray;
-(CGPoint) tilePositionForCoord:(CGPoint) coord;

-(void)moveOnPath;

+(id) scene;

+(NSString*) getDefaultLevel; 
-(void) loadMap;

-(void)setViewpointCenter:(CGPoint) position;
-(CGPoint)tileCoordForPosition:(CGPoint)position;
-(CGPoint)positionForTileCoord:(CGPoint)tileCoord;


@end
